-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------

-- Your code here

local image  = display.newImage( "20120205_DOG_01.jpg" )

image.height = display.contentWidth
image.width = display.contentHeight

image.x = display.contentWidth / 2
image.y = image.height / 2

local textObject = display.newText( "Wow~!", 0, 0, native.systemFont, 20 )
local function startProcessor( obj )
	textObject.rotation = textObject.rotation + 10
end
local function endProcessor( obj )
	textObject.rotation = textObject.rotation + math.random( 6, 8 )
end

function image:tap( event )
	local nextAlpha = self.alpha - 0.1
	if nextAlpha < 0.0 then
		nextAlpha =  0.0
	end
	
	local transitionOption = {
		time = 500,
		transition = easing.linear,
		delay = 2,
		alpha = nextAlpha,
		y = self.y + 10,
		
		onStart = startProcessor,
		onComplete = endProcessor
	}

	transition.to( self, transitionOption )
end
image:addEventListener( "tap" )
